home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / MorphOS / Epic4_mos / share / epic / script / utime < prev    next >
Encoding:
Text File  |  2002-10-28  |  1.1 KB  |  54 lines

  1. #
  2. # Here's the plan
  3. # Kanan wants a way to manipulate $utime() values.  Because theyre 
  4. # thrown about as two words, we cant actually have the math parser
  5. # handle them automatically (alas), and writing built in functions
  6. # just to do this seems like overkill.  So i wrote these aliases for
  7. # his (and your) convenience.  Use this is as a starting point for you
  8. # own alias needs, or drop me a line if you have more suggestions.
  9. # (jnelson@acronet.net)
  10. #
  11.  
  12. #
  13. # Add two utimes.
  14. #
  15. alias utime_add 
  16. {
  17.     local sec,usec
  18.     @ sec = [$0] + [$2]
  19.     @ usec = [$1] + [$3]
  20.     if (usec > 1000000)
  21.     {
  22.         @ usec -= 1000000, sec++
  23.     }
  24.     @ function_return = sec ## [ ] ## right(6 000000$usec)
  25. }
  26.  
  27. #
  28. # Subtract two utimes.  The LARGER utime (the more recent) should
  29. # be the first one specified
  30. #
  31. alias utime_sub
  32. {
  33.     local sec,usec
  34.     @ sec = [$0] - [$2]
  35.     @ usec = [$1] - [$3]
  36.     if (usec < 0)
  37.     {
  38.         @ usec += 1000000, sec--
  39.     }
  40.     @ function_return = sec ## [ ] ## right(6 000000$usec)
  41. }
  42.  
  43. #
  44. # You pass a utime as $0, $1, and this function will return
  45. # how many useconds have passed since then.
  46. #
  47. alias time_since
  48. {
  49.     local now $utime()
  50.     @ function_return = utime_sub($now $0 $1)
  51. }
  52.  
  53. #hop'97
  54.